import Vue from 'vue';
import OpenAppTip from '@/components/OpenTips.vue';

const WechatModal = Vue.extend(OpenAppTip);

let instance = null;

function showWechatModal({ lang }) {
  if (instance) return;
  instance = new WechatModal();
  instance.lang = lang;
  instance.$once('openTipHide', () => {
    document.body.removeChild(instance.$el);
    instance.$destroy();
    instance = null;
  });
  instance.$mount();
  document.body.appendChild(instance.$el);
}

export default showWechatModal;
